Page({
  data: {
    pageIndex: 1,
    noMore: false,
    logs: []
  },
  onLoad: function () {
    this.setData({
      account: wx.getStorageSync('rf_member')['account']
    });
    this.getLogs();
  },
  onPageScroll: function (e) {
    this.setData({
      scrollTop: e.scrollTop
    });
  },
  getLogs: function () {
    if (this.data.noMore) return;
    wx.util.request('user.statement', {
      query: `page=${this.data.pageIndex}`
    }).then(logs => {
      let _logs = this.data.logs;
      for (let item of logs) {
        item.date = wx.time.toDate(item.updated_at);
        _logs.push(item);
      }
      this.setData({
        logs: _logs,
        pageIndex: this.data.pageIndex + 1,
        noMore: logs.length < 10
      });
    });
  },
  more: function () {
    this.getLogs();
  }
})